package com.learn.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.learn.service.SysUserService;
import com.learn.dao.SoverDao;
import com.learn.entity.SoverEntity;
import com.learn.service.SoverService;


@Service("soverService")
public class SoverServiceImpl implements SoverService {
    @Autowired
    private SoverDao soverDao;

    @Autowired
    private SysUserService sysUserService;

    @Override
    public SoverEntity queryObject(Long id) {
        SoverEntity entity = soverDao.queryObject(id);

        if (this.sysUserService.queryObject(entity.getUser()) != null)
            entity.setSysUserEntity(this.sysUserService.queryObject(entity.getUser()));

        return entity;
    }

    @Override
    public List<SoverEntity> queryList(Map<String, Object> map) {
        List<SoverEntity> list = soverDao.queryList(map);
        for (SoverEntity entity : list) {
            if (this.sysUserService.queryObject(entity.getUser()) != null)
                entity.setSysUserEntity(this.sysUserService.queryObject(entity.getUser()));
        }
        return list;
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return soverDao.queryTotal(map);
    }

    @Override
    public void save(SoverEntity sover) {
        soverDao.save(sover);
    }

    @Override
    public void update(SoverEntity sover) {
        soverDao.update(sover);
    }

    @Override
    public void delete(Long id) {
        soverDao.delete(id);
    }

    @Override
    public void deleteBatch(Long[] ids) {
        soverDao.deleteBatch(ids);
    }

}
